#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=1e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//

int n,q;
ll a[N],b[N];
void solve()
{
	cin>>n>>q;
	for(int i=1;i<=n;i++) cin>>a[i];

	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) b[i]=b[i-1]+a[i];
	//sort(a+1,a+n+1);

	ll x,k;
	while(q--)
	{
		cin>>k>>x;
		// int pos=upper_bound(a+1,a+n+1,x)-a;pos--;
		// cout<<b[pos]-b[max(pos-k,0ll)]<<'\n';
		ll t=upper_bound(a+1,a+1+n,x)-a-1;
		cout<<b[t]-b[max(0ll,t-k)]<<'\n';
	}

}


int main()
{
	close();
	//int T; cin>>T;
	//while (T--) solve();
	solve();
	return 0;
}